<?php
/*
$type = $_GET['typeRequest'];

switch($type) {
	case 'theme' :
		echo $theme;break;
	case 'congres' :
		echo $congres;break;
	case 'tout_C' :
		echo $congres;break;
	case 'tout_T' :
		echo $theme;break;
}
*/

function get_meetings() {
	$xml;
	if (file_exists('temp/congress2007.xml')) {
    	$xml = simplexml_load_file('temp/congress2007.xml');
    	$xml = $xml->xpath('conference/titre/TitreConference | conference/lieu');
    	$xml2 = new SimpleXMLElement('<meetings></meetings>');
    	$i =0;
    	while($i < count($xml)) {
	    	$meeting_xml = $xml2->addChild('meeting');
	    	$meeting_name = str_replace( array("\n", "\r", "\t"), array(' ', ' ', ' '), $xml[$i]);
	    	$meeting_loc = str_replace( array("\n", "\r", "\t"), array('', '', ''), $xml[($i+1)]->Lieu);
	    	$meeting_xml->addChild('name', $meeting_name);
	    	$meeting_xml->addChild('lieu', $meeting_loc);
	    	$i += 2;
    	}
	}
	
	//echo $xml2->asXML();
	header('Content-type: application/json');
	
	echo json_encode($xml2);
}

get_meetings();
$theme = '[
				[\'Tous les theme\',
				 43.715977,7.263859,
				 6,
				 [
				     [\'Congres 1\',30],
				     [\'Congres 2\',10],
				     [\'Congres 3\',40],
				     [\'Congres 4\',10],
				     [\'Congres 5\',10]
				 ]
				],
                [\'Congrés 1\',
                 43.700977,7.240859,
                 4,
                 [
                     [\'Congres 1\',5],
                     [\'Congres 2\',30],
                     [\'Congres 3\',50],
                     [\'Congres 4\',5],
                     [\'Congres 5\',10]
                 ]
                ],
                [\'Congrés 2\',
                 43.705977,7.243859,
                 5,
                 [
                  	[\'Congres 1\',10],
                    [\'Congres 2\',5],
                    [\'Congres 3\',5],
                    [\'Congres 4\',20],
                    [\'Congres 5\',6]
                 ]
                ],
                [\'Valrose INFO!\',
                 43.715977,7.263859,
                 3,
                 [
                    [\'Congres 1\',5],
                    [\'Congres 2\',5],
                    [\'Congres 3\',5],
                    [\'Congres 4\',5],
                    [\'Congres 5\',80]
                 ]
                ],
                [\'Congrés 3\',
                 43.735977,7.283859,
                 2,
                 [
                    [\'Congres 1\',1],
                    [\'Congres 2\',1],
                    [\'Congres 3\',1],
                    [\'Congres 4\',1],
                    [\'Congres 5\',96]
                 ]
                ],
                [\'Congrés 4\',
                 43.785977,7.233859,
                 1,
                 [
                  	[\'Congres 1\',20],
                    [\'Congres 2\',20],
                    [\'Congres 3\',20],
                    [\'Congres 4\',20],
                    [\'Congres 5\',20]
                 ]
                ]
               ]';
$congres = '[
				[\'Tous les congres\',
				 43.715977,7.263859,
				 6,
				 [
				     [\'Thème 1\',30],
				     [\'Thème 2\',10],
				     [\'Thème 3\',40],
				     [\'Thème 4\',10],
				     [\'Thème 5\',10]
				 ]
				],
                [\'Congrés 1\',
                 43.700977,7.240859,
                 4,
                 [
                     [\'Thème 1\',5],
                     [\'Thème 2\',30],
                     [\'Thème 3\',50],
                     [\'Thème 4\',5],
                     [\'Thème 5\',10]
                 ]
                ],
                [\'Congrés 2\',
                 43.705977,7.243859,
                 5,
                 [
                  	[\'Thème 1\',10],
                    [\'Thème 2\',5],
                    [\'Thème 3\',5],
                    [\'Thème 4\',20],
                    [\'Thème 5\',6]
                 ]
                ],
                [\'Valrose INFO!\',
                 43.715977,7.263859,
                 3,
                 [
                    [\'Thème 1\',5],
                    [\'Thème 2\',5],
                    [\'Thème 3\',5],
                    [\'Thème 4\',5],
                    [\'Thème 5\',80]
                 ]
                ],
                [\'Congrés 3\',
                 43.735977,7.283859,
                 2,
                 [
                    [\'Thème 1\',1],
                    [\'Thème 2\',1],
                    [\'Thème 3\',1],
                    [\'Thème 4\',1],
                    [\'Thème 5\',96]
                 ]
                ],
                [\'Congrés 4\',
                 43.785977,7.233859,
                 1,
                 [
                  	[\'Thème 1\',20],
                    [\'Thème 2\',20],
                    [\'Thème 3\',20],
                    [\'Thème 4\',20],
                    [\'Thème 5\',20]
                 ]
                ]
               ]';
?>

